!function () {
    var apis = {
        dicts: {
            url: '/api/public/v1/cache/dicts'
        },
        flows: {
            url: '/api/public/v1/cache/flows'
        },
        modules: {
            url: '/api/public/v1/cache/modules'
        },
        mirrors: {
            url: '/api/public/v1/cache/mirrors'
        },
        stores: {
            url: '/api/public/v1/cache/stores'
        },
        login: {
            url: '/api/public/v1/user/login',
            method: 'POST'
        },
        logout: {
            url: '/api/public/v1/user/logout'
        },
        change_password: {
            url: '/api/public/v1/user/change_password',
            method: 'POST'
        },
        user_load: {
            url: '/api/public/v1/user/load'
        },
        user_edit: {
            url: '/api/public/v1/user/edit',
            method: 'POST'
        },
        upload_params: {
            url: '/api/public/v1/upload/params?type=image'
        },
        app_menu: {
            url: '/api/public/v1/app/menu?type=web'
        }
    }
    window.publicApi = function (apiName, apiData) {
        var apiInfo = $.extend(true, {}, apis[apiName]);
        if (!apiInfo.dataType) {
            apiInfo.dataType = 'json';
        }
        if (apiData) {
            apiInfo.data = apiData;
        }
        apiInfo.url = HOST + apiInfo.url;
        return $.ajax(apiInfo).then(function (data) {
            return data;
        }, function (err) {
            utils.requestError(err);
        });
    };
    window.publicApi.uptoken_url = HOST + '/api/public/v1/upload/params?type=image';
}();